# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>

pkgname=rizin
pkgver=0.5.2
pkgrel=1
pkgdesc='Open-source tools to disasm, debug, analyze and manipulate binary files'
url='https://rizin.re'
arch=('loong64' 'x86_64')
license=('GPL3' 'LGPL3')
depends=(
  sh
  capstone libcapstone.so
  openssl
  libzip libzip.so
  zlib
  lz4
  xz
  xxhash libxxhash.so
  file libmagic.so
  tree-sitter libtree-sitter.so
  libmspack libmspack.so
)
makedepends=('meson' 'ninja' 'python' 'python-yaml')
optdepends=('rz-ghidra: ghidra decompiler plugin')
options=('!emptydirs')
source=(https://github.com/rizinorg/rizin/releases/download/v${pkgver}/rizin-src-v${pkgver}.tar.xz)
sha512sums=('2fbd3873c7725d4fa1dee53d685c4a5d372013f300cd19dd92752b82987f049a4eba77b4d4ae33b576678714752147355ac486951949a35275cc3fdc5447a351')
b2sums=('d74c02c1f58d099a0047a7a528b7e182980901bc1bf2722aef259e03ddf9af908c3ebcde4f1268fcbd07125a21f064259601a54c6b8413e19f6b85c95113cf3d')

build() {
  cd ${pkgname}-v${pkgver}
  arch-meson build \
    -D use_sys_capstone=enabled \
    -D use_capstone_version=v4 \
    -D use_sys_magic=enabled \
    -D use_sys_libzip=enabled \
    -D use_sys_lz4=enabled \
    -D use_sys_lzma=enabled \
    -D use_sys_zlib=enabled \
    -D use_sys_xxhash=enabled \
    -D use_sys_openssl=enabled \
    -D use_sys_tree_sitter=enabled \
    -D use_sys_libmspack=enabled \
    -D use_zlib=true \
    -D use_lzma=true \
    -D local=disabled
  ninja -C build
}

package() {
  cd ${pkgname}-v${pkgver}
  DESTDIR="${pkgdir}" ninja -C build install
  install -d "${pkgdir}/usr/share/doc/rizin"
  cp -r doc/* "${pkgdir}/usr/share/doc/rizin"
}

# vim: ts=2 sw=2 et:
